 
# include <stdio.h>
struct stack    
 {	int n;       
  	char x,y,z;  
 }	sta[200];   
 void Hanniota(int n,char fr,char by,char to)
{
	int top=-1;   
	int n1,a,b,c; 
	top=top+1;
	sta[top].n=n;
	sta[top].x=fr;
	sta[top].y=by;
	sta[top].z=to;
	while(top>-1)
	 {
		n1=sta[top].n;
		a=sta[top].x;
		b=sta[top].y;
		c=sta[top].z;
		top--;
	if(n1>1)
	    {top++; 
			sta[top].n=n1-1;
			sta[top].x=b;
			sta[top].y=a;
			sta[top].z=c;
	     top++;          
			sta[top].n=1;
			sta[top].x=a;
			sta[top].z=c;
	     top++;           
			sta[top].n=n1-1;
			sta[top].x=a;
			sta[top].y=c;
			sta[top].z=b;
	    }
	else
		printf("move  %c --> %c\n",a,c);
	 }
	}
 int main()
{
	Hanniota(3,'A','B','C');
	return 0;
}

